package system

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type SysSession struct {
	SessionId   int64     `orm:"column(session_id);pk"`
	AdminId     uint64    `description:"账号ID"`
	OpenId      string    `description:"openid"`
	AccessToken string    `description:"登录token"`
	ExpireTime  time.Time `description:"超时时间"`
	CreateTime  time.Time `description:"创建时间"`
	ModifyTime  time.Time `description:"修改时间"`
}

type LoginTokenContent struct {
	AdminId    uint64
	Password   string
	IsRemember bool `description:"是否属于受信设备"`
}

// Add 新增
func (s *SysSession) Add() (lastId int64, err error) {
	o := orm.NewOrm()
	lastId, err = o.Insert(s)
	return
}

//func (s *SysSession) GetSessionByToken(token string) (item *SysSession, err error) {
//	err = global.DEFAULT_MYSQL.Model(s).Where("access_token = ? ", token).Order("session_id DESC").First(&item).Error
//	return
//}
